#ifndef __SERIAL_H__
#define	__SERIAL_H__

#ifdef __cplusplus
extern "C" {
#endif

#define SERIAL_DEV "/dev/ttyACM0"
#define TRIGER_DEV "/dev/trigger"
#define MAX_BUFFER	256
#define TRUE	1
#define FLASE	0
#define MSG_LEN 150

#define msleep(ms) usleep(ms*1000)

#define VERIFICATION	1	/* system time vs gps time, verification deviation */

/*
 * function abstruct : uart initialization
 * parameter illustration: 
 *		[com]: uart number,[baudrate]: baud rate, [databit]: data bit
 *		[stopbit]: stop bit, [parity]: parity
 */
int uart_init(int com, int baudrate, int databit, int stopbit, char parity);
int uart_receive(unsigned char * buffer, int len);
int uart_send(unsigned char * buffer, int len);

int time_analysis(char * pdata);

void * uart_receive_thread(void * param);
void * uart_send_thread(void * param);

int trigger_open();
int trigger_jump();

#ifdef VERIFICATION
long get_gps_seconds(long tv_sec);
int display_gps_time(long tv_sec);
int get_system_time(void);
void * display_system_time(void * param);
int display_gps_microsecond(long tv_sec, long tv_usec);
int get_system_time_microsecond(void);
#endif

#ifdef __cplusplus
}
#endif

#endif /* __SERIAL_H__ */